/**
 * Created by user on 2015/9/28.
 */

angular.module('mis.dataSyncManager.controllers', [])
    .controller('dataSyncCtrl', ['$scope','$http', '$location', function ($scope, $http, $location) {


        $scope.secondHand = function(){


            var body = {city:'54d862bb573a6d301441b94f'};

            if ($("#startDate").val()) body.startDate = $("#startDate").val() + ' 00:00:00';
            if ($("#endDate").val()) body.endDate = $("#endDate").val() + ' 23:59:59';
            if (body.startDate && body.endDate && body.startDate > body.endDate) {
                alert('开始日期不能大于结束日期');
                return;
            }

            $http.post('http://' + backOfficeHost + '/rest/v1.0/mis/dataSync/secondHandSync', body, {
                headers: {'Content-Type': 'application/json;charset=utf-8'}
            }).success(function (data) {

                $('#loading').modal("close");

                if(data.result.status == 0){
                    alert(data.result.message);
                }else {
                    alert("二手数据同步成功！");
                };

            }).error(function (err) {
                $('#loading').modal("close");
                alert(err);

            });

        };


    }])